package thread.synchronize.different;

/**
 * @author cuihao
 * @date 2018/3/4
 */
public class Var {

    synchronized public void methodA() {
        try {
            String a = "sfd" + System.currentTimeMillis();
            System.out.println(a);
            System.out.println(Thread.currentThread().getName() + " run method A " + System.currentTimeMillis());
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    public void methodB() {
        synchronized (this) {
            System.out.println(Thread.currentThread().getName() + " run method B " + System.currentTimeMillis());
        }
    }

    public void methodC() {
        String syn = "synchtronized";
        synchronized (syn) {

            System.out.println(Thread.currentThread().getName() + " run method C " + System.currentTimeMillis());
        }
    }

}
